<template>
  <div id="content-table">
    <div class="content-table-item" v-for='(item,index) in topList' :key='index'>
      <div class="content-table-item-top">
        <img :src="item.coverImgUrl" alt="" class="table-main" />
        <div class="content-table-item-title">{{item.name}}</div>
        <img
          :src="playUrl[index]"
          alt=""
          class="table-play"
          @mousemove="playUrl[index] = require('../../../assets/播放动态.png')"
          @mouseout="playUrl[index] = require('../../../assets/播放.png')"
        />
        <img
          :src="collectUrl[index]"
          alt=""
          class="table-collect"
          @mousemove="collectUrl[index] = require('../../../assets/收藏动态.png')"
          @mouseout="collectUrl[index] = require('../../../assets/收藏.png')"
        />
      </div>
      <div class="table-body" v-for='(items,indexs) in listDetail[index].tracks.slice(0,10)' :key='indexs'
      :class="{'table-bodys': (indexs+1)%2 == 0}">
        <span class="table-body-index" :class="{'table-body-indexs': (indexs + 1) <= 3}">{{indexs + 1}}</span>
        <span class="table-body-text"><a href="">{{items.name}}</a></span>
      </div>
      <div class="table-more">
          <a href="">查看更多&gt;</a>
      </div>
    </div>
  </div>
</template>

<script>
import { getTopList,getListDetail } from "@/api/home";
export default {
  name: "ContentTable",
  created() {
    getTopList().then((res) => {
      for(var i = 0; i < 3; i++){
          let temp = res.data.list[i]
          this.topList.push(temp)
          getListDetail( temp.id ).then(res => {
                  this.listDetail.push(res.data.playlist)
          })
        }
        console.log(this.listDetail)
    });
  },
  data() {
    return {
      playUrl: [require("../../../assets/播放.png"),
      require("../../../assets/播放.png"),
      require("../../../assets/播放.png")],
      collectUrl: [require("../../../assets/收藏.png"),
      require("../../../assets/收藏.png"),
      require("../../../assets/收藏.png")],
      topList:[],
      listDetail:[],
    };
  },
  methods: {},
};
</script>

<style>
#content-table {
  width: 100%;
  height: 470px;
  position: relative;
  margin-top: 20px;
  border: 1px solid #ccc;
  border-left: none;
  display: flex;
}
.content-table-item {
  flex: 1;
  border-left: 1px solid #ccc;
  height: 100%;
}
.content-table-item-top {
  height: 120px;
  width: 100%;
  background: #f4f4f4;
  -webkit-box-shadow: 0px 1px 1px #f1f1f1;
  -moz-box-shadow: 0px 1px 1px #f1f1f1;
  box-shadow: 0px 1px 1px #f1f1f1;
  position: relative;
}
.table-main {
  height: 80px;
  width: 80px;
  margin-top: 20px;
  margin-left: 20px;
  cursor: pointer;
}
.content-table-item-title {
  font-weight: bolder;
  font-size: 18px;
  position: absolute;
  top: 25px;
  left: 115px;
}
.table-play {
  width: 25px;
  height: 25px;
  position: absolute;
  left: 113px;
  top: 55px;
  cursor: pointer;
}
.table-collect {
  width: 25px;
  height: 25px;
  position: absolute;
  left: 144px;
  top: 55px;
  cursor: pointer;
}
.table-body {
  width: 100%;
  -webkit-box-shadow: 0px 1px 1px #f1f1f1;
  -moz-box-shadow: 0px 1px 1px #f1f1f1;
  box-shadow: 0px 1px 1px #f1f1f1;
  height: 32px;
  line-height: 32px;
  background: #e8e8e8;
  position: relative;
}
.table-bodys{
    background: #f4f4f4 !important;
}
.table-body-index{
    font-weight: bolder;
    color: #666666;
    position: absolute;
    left: 25px;
}
.table-body-indexs{
    color: #c10d0c !important;
}
.table-body-text{
    font-weight: none;
    font-size: 14px;
    position: absolute;
    left: 48px;
}
.table-body-text a{
    color: black;
}
.table-more{
    background:#e8e8e8;
    height: 32px;
    width: 100%;
    line-height: 32px;
    position: relative;
    font-size: 12px;
}
.table-more a{
    color: black;
    position: absolute;
    right: 25px;
}
</style>